home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / areuh.tar / areuh / doc / compc.doc < prev    next >
Text File  |  1990-10-10  |  16KB  |  340 lines

  1.             COMMUNICATION HP-71 <=> PC
  2.  
  3.               Michael Markov (PPC Paris 301)
  4.  
  5.  
  6. This file documments three HP-71 programs I use to upload and download files to
  7. and from my HP110. They can also be used to do the same with IBM PC or
  8. compatible machines equipped with an HP82973 HPIL Interface.
  9.  
  10. Why do I need special programs to do this, when HPILLINK provides the ability
  11. to upload and download files from the PC keyboard? Because I only want to
  12. exchange files with the PC, not use a remote keyboard for my HP-71. The editor
  13. I have on the PC or the HP110 (Ed Gilbert's Editor, NOT memomaker) is much
  14. faster than any text editors I have on the HP-71, they handle long text files
  15. without slowing down to the speed of cold molasses, and have features HP-71
  16. users only dream of. Editing BASIC programs is usually faster without the delays
  17. introduced by the remote keyboard. Finally - HPILLINK set-up with the remote
  18. keyboard does a number of unfriendly things, such as mess-up my STARTUP, my key
  19. assignments, or even FREEPORT memory I do not want FREEPORTED, if I do not have
  20. KEYBOARD LEX in my machine.
  21.  
  22. Still, it is nice to have mass storage and printers at work, by way of HPILLINK
  23. and the IBM XT in my department. Being able to share data stored in my HP-71
  24. using the HPILLINK /C option helps keep my bosses happy with my HP-71. Hence,
  25. the routines below.
  26.  
  27. NOTE: LINK 1.02 (Southern Software) provides similar capabilities. I hear there
  28. soon will be a new version called LINK PLUS, with many interesting features.
  29. I use LINK 1.02 rather than HPILLINK if I want to use the PC as a printer or
  30. as a video interface for my HP-71. 
  31.    
  32. The first program is intended to upload or download a single file at a time,
  33. from the HP-71 keyboard. Before using this program, you must run the
  34. HPILLINK.EXE program on the PC, and connect the HP-71 to the PC HP-IL port.
  35.  
  36. When you download a file, you must provide the full file name, such as:
  37. JUNK.TEX
  38.  
  39. When you upload a file, the program will automatically supply the correct file
  40. extension if you have the FTYPE$ keyword available. See source code below.
  41. If not, the extension will be left blank, and you will have to RENAME the file
  42. from the PC keyboard if you want the correct extension.
  43.  
  44. The file transfer takes little or no time. Once done, disconnect the HP-71,
  45. exit HPILLINK with the F8 key, and do whatever you desire with either the PC or
  46. the HP-71. Enjoy! 
  47.  
  48.  
  49. 0010 ! PC71EX - Transfer HP71 files between a PC and an HP71 with HPILLINK
  50. 0020 ! Copyright Michael Markov 1988
  51. 0030 ! 
  52. 0040 ! Uses FTYPE$ keyword from DATACOM ROM - See FLTYPELXS for source
  53. 0050 ! This is required if you want to provide the proper file extension
  54. 0060 ! when uploading files to an IBM PC via HPILLINK /HP82973 Interface card
  55. 0070 ! or to an HP110 running HPILLINK.
  56. 0080 ! 
  57. 0090 ! If you do not have the FTYPE$ keyword, comment-out the line 300 :
  58. 0100 ! 300 T$=FTYPE$(F$)
  59. 0110 ! 
  60. 0120 ! The advantage of this program is that it allows file transfers without
  61. 0130 ! messing-up your favorite STARTUP, your key assignments, or FREEPORTing
  62. 0140 ! stuff you may not want free-ported. This was developed when I started
  63. 0150 ! to make heavy use of my HP110 to edit HP71 source code files, which I
  64. 0160 ! then assembled using the AREUH (PPC-Paris) assembler-linker before 
  65. 0170 ! downloading the resulting LEX for testing in the HP71. I had no need for
  66. 0180 ! an external keyboard since the EDITOR I use on my HP110 is considerably
  67. 0190 ! faster than EDTEXT, and provides more flexibility.
  68. 0200 ! 
  69. 0210 LOCAL @ DISP 'Up or Download?(U/D)'
  70. 0220 A$=UPRC$(KEYWAIT$) @ IF A$='D' THEN 240
  71. 0230 IF A$='U' THEN 280 ELSE 210
  72. 0240 LOCAL @ INPUT 'DOWNLOAD FILE? ';F$ @ IF F$='' THEN END 
  73. 0250 P=DEVADDR(':PC')
  74. 0260 SEND UNT TALK P DDT 0 UNT MTA LISTEN P DATA F$ EOL 
  75. 0270 COPY :P @ GOTO 240
  76. 0280 INPUT 'Upload file? ';F$ @ IF F$='' THEN END 
  77. 0290 P=DEVADDR(':PC') @ T$=''
  78. 0300 T$=FTYPE$(F$)[1,3] ! comment out if FTYPES keyword not available
  79. 0310 SEND UNL LISTEN P MTA DDL 0 DATA F$,'.',T$,10 
  80. 0320 COPY F$ TO :P @ GOTO 280
  81.  
  82. The second program is a minor variant of the PC71EX program given above. It
  83. allows you to upload or download ROM images just as if the PC was an HPIL disk
  84. drive. There is one interesting difference: the file stored on the DOS disk will
  85. take less space than on HPIL mass storage. Apparently, HPILLINK and ROMCOPY
  86. version RCPY:E were designed to work together better than the mass storage
  87. option! Here, we see the advantages of an intelligent mass storage device.
  88.  
  89. 0010 ! PCROM - Transfer HP71 ROM images between a PC and an HP71 with HPILLINK
  90. 0011 ! and ROMCOPY LEX.
  91. 0020 ! Copyright Michael Markov 1988
  92. 0030 ! 
  93. 0040 ! This program is a slightly modified version of PC71EX, elsewhere on this
  94. 0041 ! swapdisk. See PCCOMM for documentation.
  95. 0042 ! 
  96. 0210 LOCAL @ DISP 'Up or Download?(U/D)'
  97. 0220 A$=UPRC$(KEYWAIT$) @ IF A$='D' THEN 240
  98. 0230 IF A$='U' THEN 280 ELSE 210
  99. 0240 LOCAL @ INPUT 'DOWNLOAD FILE? ';F$ @ IF F$='' THEN END 
  100. 0241 INPUT 'To :PORT(#)? ','5';N
  101. 0250 P=DEVADDR(':PC') @ IF NOT POS(F$,'.ROM') THEN F$=F$&'.ROM'
  102. 0260 SEND UNT TALK P DDT 0 UNT MTA LISTEN P DATA F$ EOL 
  103. 0261 X=POS(UPRC$(F$),'.ROM') @ F$=F$[1,X-1]&':'&STR$(P)
  104. 0270 ROMCOPY F$ TO ':PORT('&STR$(N)&')' @ GOTO 240
  105. 0280 INPUT 'Upload file? ';F$ @ IF F$='' THEN END 
  106. 0281 INPUT 'From :PORT(#)? ','5';N
  107. 0290 P=DEVADDR(':PC') @ X=POS(UPRC$(F$),'.ROM') @ IF X THEN F$=F$[1,X-1]
  108. 0310 SEND UNL LISTEN P MTA DDL 0 DATA F$,'.ROM',10 
  109. 0320 ROMCOPY ':PORT('&STR$(N)&')' TO :P @ GOTO 280
  110.  
  111. The last program allows you to upload many files to the PC, under the control
  112. of an HP-71 program. I have used it to transfer entire swapdisks to my HP110,
  113. for friends that have HP-71 machines and PC's, but not HP9114 drives. They then
  114. read the disks as best they can. I understand that there is a new package from
  115. Personalized Software called READHP, that allows IBM machines to read 3.5" disks
  116. formatted by HP machines.
  117.  
  118. It should be possible to download files from the PC with a PCTODISK program,
  119. just as easily as you can upload entire disks. The easiest approach would be
  120. to start things going by creating a TEXT file with all the desired filenames
  121. and extensions with the DIR A: >DIR.TEX. Then use PC71EX to download the file,
  122. and let your HP-71 control the download to an HPIL mass storage device. I have
  123. not needed to do this, since I am not (as of this date) getting any
  124. contributions on DOS disks. However, if HP abandons HPIL, this may be the only
  125. way to have peripherals for our HP41/HP75/HP71 computers, may they last many
  126. years. (Have you purchased a spare HP-71 yet? NO? Why?).
  127.  
  128. NOTE: PCTODISK does not yet exist, except as an idea. It is one of my many
  129. 'to do sometime' projects.
  130.  
  131. Anyways, easy PC<==>HP71 communications will greatly ease the transition to the
  132. world of DOS/OS2 machines, where instead of HP BASIC you will be forced to learn
  133. PASCAL, C, MEGA BASIC or QUICK BASIC if you want to do any serious programming.
  134.    
  135. Obvioulsy, the PC must be running HPILLINK, and the default drive to which 
  136. HPILLINK writes the files should be as empty as possible. Load HPILLINK with
  137. A:HPILLINK, then replace the disk in the default drive (usually A:) with a
  138. newly formated disk. On the HP71, run DISKTOPC. When the program stops, replace
  139. the disk in the default drive, and run DISKTOPC on the HP71 to continue the
  140. upload.
  141.  
  142. NOTE: Do NOT purge the temporary directory file (default DIRFL), except at the
  143. start of the upload, before the first file is transfered. This allows the PDIR
  144. keyword (JPCROM) to create a new file that contains all the information you need
  145. to upload the disk. The HP-71 automatically deletes file entries as the upload
  146. goes on. Any time the DISKTOPC program stops, you can LIST DIRFL to find out
  147. how many files still ave to be uploaded.
  148.  
  149. Note that the program polls the PC to determine whether the remote load failed
  150. for any reason, such as no space remaining available on the PC. This program is
  151. intended to be used in conjunction with a video interface on the HPIL loop.
  152.  
  153. The program uses JPCROM to create a directory listing of the disk to be
  154. uploaded to the PC. This is by far the most convenient way. Among other things,
  155. JPCROM implements a poll handler that allows your HP-71 to identify HP-41,
  156. HP-75 and other non-HP71-standard file types. This allows you to tag the file
  157. names to help identify the contents of the file. HPILLINK does not recognize
  158. HP-41 or HP-75 file types. In fact, it does not recognize all HP-71 file types,
  159. atleast, not the version I have (Maybe revision E does better, but I do not have
  160. that yet. 
  161.  
  162. It should be obvious that minor changes to line 240 allow uploading only HP-71
  163. files, or only HP41 files, etc, should you so desire.
  164.  
  165. 0010 ! DISKTOPC - UPLOAD FILES TO PC WITH HPILLINK
  166. 0020 ! This program is available, at least in concept, in the HPILLINK
  167. 0030 ! documentation. It implements the task in a way that helps minimizes
  168. 0040 ! user intervention. It was written to facilitate uploading Swapdisks
  169. 0050 ! to an IBM PC equipped with an HPIL interface card.
  170. 0060 ! 
  171. 0070 ! Since the HP71 is the controller, you can have a disk drive on the loop,
  172. 0080 ! and copy each file from the drive to the IBM PC, using a minimum of
  173. 0090 ! HP-71 memory.
  174. 0100 ! JPCROM REQUIRED. IF NOT AVAILABLE, CREATE DISK DIRECTORY LISTING WITH
  175. 0110 ! SOME BASIC ROUTINE SUCH AS DIR71
  176. 0120 CONTROL ON @ RESET HPIL @ RESTORE IO @ DISPLAY IS :DISPLAY
  177. 0130 INPUT "Which drive? ";D
  178. 0140 P=DEVADDR('%16('&STR$(D)&')')
  179. 0150 INPUT 'temp. file? ','DIRFL';F$
  180. 0155 ON ERROR GOTO 161
  181. 0160 PDIR :P TO F$ @ GOTO 169
  182. 0161 OFF ERROR @ DISP ERRM$;'Purge? (Y/N)'
  183. 0162 A$=UPRC$(KEYWAIT$) @ IF A$='Y' THEN PURGE F$ @ GOTO 155
  184. 0169 OFF ERROR @ ASSIGN #1 TO F$ @ RESTORE #1
  185. 0180 DIM A$[60] @ D=DEVADDR(':PC') @ STANDBY ON @ REMOTE 
  186. 0190 FOR I=0 TO FILESZR(F$)-1 @ READ #1;A$ @ DISP I;A$
  187. 0200 IF SPOLL(D)#5 THEN 270
  188. 0210 F$=TRIM$(A$[1,10])
  189. 0220 T$=TRIM$(A$[14,19])[1,3]
  190. 0230 IF T$='41:' OR T$='75:' THEN G$=F$&T$[1,2] @ T$='UNK' ELSE G$=F$
  191. 0240 SEND UNL LISTEN D MTA DDL 0 DATA G$,'.',T$,10 
  192. 0250 COPY F$&':'&STR$(P) TO :D
  193. 0260 NEXT I
  194. 0270 LOCAL @ DISP 'HP110 Drive A full-delete last file copied'
  195. 0280 READ #1,I-2;A$ @ DISP 'last file copied: ';I-2;A$
  196. 0281 FOR J=I-2 TO 0 STEP -1 @ DELETE #1,J @ NEXT J
  197. 0290 STANDBY OFF @ CONTROL OFF @ END 
  198.  
  199.        LEX    'FTYPELEX'  LEX file name
  200.        TITLE  FTYPELEX, File type LEX,  Samuel H Chau [242]
  201. *
  202.        ID     #F6         compatible with DCLEX in DATACOMM ROM
  203.        MSG    0           no message table
  204.        POLL   0           no poll handler
  205. *
  206.        ENTRY  FTYPE
  207.        CHAR   #F          string function
  208. *
  209.        KEY    'FTYPE$'    Syntax: FTYPE$('file specifier') or
  210. *                                 FTYPE$(assign channel #)
  211. *                         Returns file type as a 5-char string
  212. *                         Null string returned if file not found
  213. *                         Example:  FTYPE$('FORTHRAM') returns FORTH
  214.        TOKEN  1
  215.        ENDTXT             end of text table
  216. ************************
  217. *      **** EQUate Table ****
  218. *
  219. AVE=D1 EQU #18BB8 update AVMEME from D1 or C
  220. BSERR  EQU #0939A BASIC system error
  221. D0=AVS EQU #09B2C set D0 to address in AVMEMS
  222. D1MSTK EQU #1954E set D1 at MTMSTK (AVMEME)
  223. FDCH#  EQU #114AC find channel # in assign table
  224. FFIB#  EQU #122EF find file number in FIB
  225. FILXQ$ EQU #09B95 filename execute for a string expression
  226. FINDF  EQU #09F77 find a file
  227. FLTDH  EQU #1B223 convert 12-digit flt to HEX integer
  228. FNRTN  EQU #0F23C function return
  229. FTYPDC EQU #06902 file type decompile
  230. FUNCR0 EQU #2F89B function scratch RAM start
  231. POLL   EQU #12337 poll LEX files with process #
  232. POPMTH EQU #1B3DB skip past item on MATH stack
  233. RSTK<R EQU #014A8 restore RSTK level(s) from RSTKBF buffer
  234. R<RSTK EQU #014DD save RSTK level(s) into RSTKBF buffer
  235. STRHED EQU #14C2E generate string head on stack
  236. pFINDF EQU #00017 poll to find a file
  237. pFSPCx EQU #00005 poll to execute file specifier
  238. eFSPEC EQU #0003A invalid filespec error
  239. *
  240. ************************
  241. *
  242.        NIBHEX C11    one string or numeric parameter
  243. FTYPE  CD0EX
  244.        RSTK=C        save D0 (PC) on return stack
  245.        GOSBVL R<RSTK save RSTK level(s)  [P=0]
  246.        A=DAT1 W      get top of MATH stack in A
  247.        LCHEX  A      load C:0 for parameter type check
  248.        ?C>A   P      integer parameter?
  249.        GOYES  FTYP03 yes: interpret as channel #
  250.        A=A+1  P
  251.        ?A#0   B      not string parameter?
  252.        GOYES  FTYP01 yes: parameter is invalid
  253.        GOTO   FTYP09 no: interpret string as file specifier
  254. FTYP01 LC(4)  eFSPEC load Invalid filespec error
  255. FTYP02 GOVLNG BSERR  BASIC error exit
  256. FTYP03 D1=D1+ 16     pop integer argument off MATH stack
  257.        GOSUB  ave=d1 update stack top pointer
  258.        GOSBVL FLTDH  convert 12 form channel # to HEX integer
  259.        B=A    B      put HEX form in B for FDCH#
  260.        GOSBVL FDCH#  find channel # in assign table
  261.        GONC   FTYP08 not found: ready for exit
  262.        ?A=0   B      channel closed? no: A(B)=FIB#
  263.        GOYES  FTYP08 yes: punt!
  264.        GOSBVL FFIB#  find file # in FIB
  265.        GOC    FTYP08 not found? yes: punt! no: D1 @ file # in FIB
  266.        D1=D1+ 5      advance to file type entry in FIB
  267. FTYP04 GOSBVL D0=AVS set D0 to AVMEMS
  268.        C=0    W      preclear C
  269.        DAT0=C W      blank out word at AVMEMS
  270.        D0=D0+ 2      point past one null
  271.        GOSBVL FTYPDC get file type (5 chars), D0 points past it
  272.        GOSUB  d1mstk set D1 to AVMEME
  273.        GOSBVL D0=AVS set D0 to AVMEMS
  274.        C=DAT0 W      get file type in C
  275.        ?C=0   B      not at file type string?
  276.        GOYES  FTYP06 yes: move pointer down
  277. FTYP05 ?C=0   B      end of file type string?
  278.        GOYES  FTYP07 yes: ready for string return
  279.        D1=D1- 2      point D1 down 1 char
  280.        DAT1=C B      push one ASCII char onto stack
  281. FTYP06 CSR    W
  282.        CSR    W      shift to next char in file type string
  283.        GOTO   FTYP05 continue building string on stack
  284. FTYP07 GOSBVL STRHED generate string header on stack
  285.        GOSBVL RSTK<R restore RSTK level(s)
  286.        C=RSTK
  287.        CD0EX         restore D0 (PC) from RSTK
  288.        GOVLNG FNRTN  function return
  289. FTYP08 GOSUB  d1mstk set D1 to AVMEME
  290.        GOTO   FTYP07 return with string
  291. FTYP09 GOSUB  ave=d1 update stack top pointer
  292.        C=DAT1 W      read string header into C
  293.        CSR    W
  294.        CSR    W      shift to string length field
  295.        ?C=0   A      null string?
  296.        GOYES  FTYP08 yes: ready for return
  297.        GOSBVL FILXQ$ execute tokenized file specifier
  298.        P=     0
  299.        LCASC  '  '   load C with 2 ASCII spaces
  300.        R0=C          save in R0
  301.        GOC    FTYP16 file specifier is mainframe recognizable
  302.        GOSBVL POLL   illegal: issue file spec execution poll
  303.        CON(2) pFSPCx file specifier execute poll
  304.        GOC    FTYP13 error return from poll: error exit
  305.        ?XM=0         pFSPCx poll handled? 
  306.        GOYES  FTYP10 yes: continue
  307.        GOTO   FTYP01 no: Invalid filespec error
  308. FTYP10 C=R0          last 2 chars of filename into C
  309.        R1=C          save in R1
  310.        R0=A          filename (blank filled) into R0
  311.        GOSUB  d1mstk set D1 to stack top
  312.        GOSBVL POPMTH skip past current item on stack
  313.        GOSUB  ave=d1 update stack top pointer
  314.        GOSBVL POLL   issue poll to find file
  315.        CON(2) pFINDF file finder poll
  316.        GONC   FTYP11 no error: continue
  317.        A=C    A      save C in A
  318.        LCHEX  16     load C with HPIL File not found error #
  319.        ?A=C   B      file not found on HPIL mass storage?
  320.        GOYES  FTYP12 yes: ready for return
  321.        C=A    A      restore C from A
  322.        GONC   FTYP13 B.E.T.
  323. FTYP11 ?XM=0         pFINDF poll handled?
  324.        GOYES  FTYP14 yes: continue
  325. FTYP12 GOTO   FTYP08 no: ready for return
  326. FTYP13 GOTO   FTYP02 load BASIC error returned from LEX file
  327. FTYP14 D1=(5) FUNCR0 set D1 to function scratch RAM
  328.        C=R0
  329.        DAT1=C W      put file attributes into function scratch RAM
  330.        D1=D1+ 11     advance to file type field
  331. FTYP15 GOTO   FTYP04 go find file type
  332. FTYP16 GOSUB  ave=d1 update stack top pointer
  333.        GOSBVL FINDF  find the file
  334.        GOC    FTYP12 not found: ready for return
  335.        D1=D1+ 16     move to file type field in file header
  336.        GONC   FTYP15 B.E.T.
  337. ave=d1 GOVLNG AVE=D1
  338. d1mstk GOVLNG D1MSTK
  339.        END
  340.